package com.jwaoo.chat;

import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.view.WindowManager;

import com.dx.as.listener.IForChatModule;
import com.jwaoo.chat.activity.module.fromapp.AppInstance;
import com.jwaoo.chat.session.SessionEventListener;
import com.jwaoo.chat.session.SessionHelper;
import com.jwaoo.chat.session.emoji.StickerManager;

/**
 * Created by jwaoo on 2017/6/14.
 */

public class ChatHelpter {
    private static Context mContext;
    // 会话窗口消息列表一些点击事件的响应处理函数
    private static SessionEventListener sessionListener;
    public static int currentSessionId = 0;

    public static void init(Context context,IForChatModule forChatModule){
        mContext = context;
        SessionHelper.init();
        StickerManager.getInstance().init();
        AppInstance.initAppInstance(forChatModule);
    }

    public static Context getContext(){
        return mContext;
    }

    /**
     * 获取聊天界面事件监听器
     *
     * @return
     */
    public static SessionEventListener getSessionListener() {
        return sessionListener;
    }

    /**
     * 设置聊天界面的事件监听器
     *
     * @param sessionListener
     */
    public static void setSessionListener(SessionEventListener sessionListener) {
        ChatHelpter.sessionListener = sessionListener;
    }

    public static WindowManager.LayoutParams getFloatConfig(WindowManager.LayoutParams layoutParams){
        if (Build.VERSION.SDK_INT >= 26){
            layoutParams.type= WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
        }else if (Build.VERSION.SDK_INT == 25) {
            layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
        }else {
            layoutParams.type = WindowManager.LayoutParams.TYPE_TOAST;
        }
        return layoutParams;
    }

}
